<template>
	<view>
		<view class="signInDetails-sign">
			<view>电子签名</view>
			<view class="signInDetails-sign-but">
				<view v-if="imgAutograph.length < 1" @click="signInClick">电子签名</view>
				<image v-else src="" mode=""></image>
			</view>
		</view>
		<catSignature canvasId="canvas" @close="close" @save="save" :visible="isShow" />
	</view>
</template>

<script>
export default {
	name: '',
	data() {
		return {
			imgAutograph: '', // 签名信息
			isShow: false
		};
	},
	onLoad(e) {
		console.log('前页面传过来的数据------', e);
	},
	methods: {
		// 点击签名
		signInClick() {
			this.isShow = true;
		},
		// 关闭
		close() {
			this.isShow = false;
		},
		// 保存
		save(val) {
			console.log(val);
			this.isShow = false;
			this.imgAutograph = val;
			uni.uploadFile({
				url: 'https://project-supervision-api.sdhuan.cn/blade-resource/oss/endpoint/put-file',
				filePath: val,
				name: 'file',
				formData: {
					file: 'multipart/form-data'
				},
				header: this.header,
				success: res => {
					console.log(JSON.parse(res.data));
					let data = JSON.parse(res.data);
					if (data.code == 200) {
						this.process.acceptanceUsers[0].acceptanceAutograph = data.data.link;
					}
				}
			});
		}
	}
};
</script>

<style lang="scss" scoped></style>
